/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sql;
import java.sql.*;
/**
 *
 * @author Donghui
 */
public class Update {
    final String url = "jdbc:mysql://localhost/isc?user=root&password=root&useUnicode=true";
    private Connection updateOpt = null;
    private Statement updateStatement = null;
    private String sql;
    private static Update local;
    private String response;

    public static Update getInstance(){
        if(local==null){
            local = new Update();
        }
        return local;
    }

    public String updateValue(String temp)
    {
        sql=temp;
        System.out.println(sql);
        try{
        Class.forName("com.mysql.jdbc.Driver");
        updateOpt = DriverManager.getConnection(url);
        updateOpt.setCatalog("isc");
        updateStatement=updateOpt.createStatement();
        updateStatement.executeUpdate(sql);
        updateStatement.close();
        updateOpt.close();
        response="1";
        }
        catch(Exception e)
        {
            e.printStackTrace();
            response="2";
        }
        return response;
    }
}
